package com.xsz.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xsz.oa.dao.UserDao;
import com.xsz.oa.helper.PasswordHelper;
import com.xsz.oa.model.entity.sys.User;

public class CreateUser {
	private static ApplicationContext ctx;

	static {
		ctx = new ClassPathXmlApplicationContext("spring.xml");
	}

	public static void main(String[] args) {
		
		UserDao userDao = (UserDao) ctx.getBean("userDao");
		
		User user = new User();
		user.setUsername("admin");
		user.setPassword("123");
		user.setRoleIdsStr("1,2,3");
		
		PasswordHelper.encryptPassword(user);
		
		userDao.create(user);
		
		System.out.println("插入成功");
	}
	
}
